import request from "@/request/request.ts";
import { pageParams, responseSkuInfo, } from "@/api/product/skuApi/interface.ts";

enum Enum {
  fetchSkuList = "/admin/product/list",
  deleteSku = "/admin/product/deleteSku",
  cancelSku = "/admin/product/cancelSale",
  saleSku = "/admin/product/onSale/",
  findSkuDetail = "/admin/product/getSkuInfo"
}

/* 获取sku列表的接口 */
export const fetchSkuListAPI = (pageParams: pageParams): Promise<responseSkuInfo> => {
  return request({
    url: `${Enum.fetchSkuList}/${pageParams.page}/${pageParams.limit}`,
    method: "GET",
  });
};

/* 删除sku的接口 */
export const deleteSkuAPI = (skuId: number): Promise<any> => {
  return request({
    url: `${Enum.deleteSku}/${skuId}`,
    method: "DELETE",
  });
};

/* 商品上架接口 */
export const saleSkuAPI = (skuId: number): Promise<any> => {
  return request({
    url: `${Enum.saleSku}/${skuId}`,
    method: "GET",
  });
};

/* 商品下架接口 */
export const cancelSkuAPI = (skuId: number): Promise<any> => {
  return request({
    url: `${Enum.cancelSku}/${skuId}`,
    method: "GET",
  });
};

/* 获取sku详情的接口 */
export const findSkuDetailAPI = (skuId: number) => {
  return request({
    url: `${Enum.findSkuDetail}/${skuId}`,
    method: "GET",
  });
};
